#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

void solve()
{
    string s;
    cin >> s;
    int n = s.size();
    int l = 1, r = 1;
    string t = s;
    if (s[0] == s[n - 1])
    {
        t[n - 1] = '0';
    }
    else
    {
        t[n - 1] = '1';
    }
    int len = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '0')
        {
            len = n - i;
            break;
        }
    }
    if (len == 0)
    {
        cout << 1 << ' ' << n << ' ' << 1 << ' ' << 1 << endl;
        return;
    }
    for (int i = 0; i <= n - len; i++)
    {
        string str = s;
        string tem = s.substr(i, len);
        for (int j = len - 1, z = n - 1; j >= 0; j--, z--)
        {
            if (tem[j] == s[z])
            {
                s[z] = '0';
            }
            else
            {
                s[z] = '1';
            }
        }
        if(s > t){
            l = i + 1, r = i + len;
            t = s;
        }
        s = str;
    }
    cout << 1 << ' ' << n << ' ' << l << ' ' << r << endl;
}

int main()
{
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}